﻿using System.Collections.Generic;
using System.Data.SqlClient;

namespace PropertyExpression.ControllableQuery.Toolkit
{
    public class CheckQueryContext
    {
        private readonly HashSet<string> hashSet = new HashSet<string>();
        public bool IsAlreadyChecked(string queryText, SqlCommand command)
        {
            return hashSet.Contains(GetKey(queryText, command));
        }

        public void AddQueryText(string queryText, SqlCommand command)
        {
            hashSet.Add(GetKey(queryText, command));
        }

        private static string GetKey(string queryText, SqlCommand command)
        {
            return queryText + FindUsagesQRepository.BuildParams(command) + command.CommandType;
        }
    }
}